package com.rc.evcharger.common.terminal;


import com.rc.evcharger.common.utils.DataUtil;

import java.math.BigDecimal;

/**
 * 后台控制充电启停命令返回结果数据域格式
 *
 * @author kb
 */
public class ElecControlResult implements Result {
    private String gunNum; // 枪号
    private String operator; // 操作相 0操作桩，1预约
    private String result; // 操作结果 0：成功 1：失败
    private BigDecimal money; // 消费金额
    private String reason; // 原因 0：枪没有插好 1：桩体其他自身原因 （操作桩原因）FF：其他原因

    private String source; //来自哪一个硬件开发商

    public ElecControlResult(String source) {
        this.source = source;
    }

    // 后台控制充电启停中，测量点0,1,2,3对应帧结构中的测量点号1,2,4,8，枪号0,1,2,3(珠海)
    //测量点号就是枪号(深圳)
    @Override
    public ElecControlResult getResult(String dataStr) {
        dataStr = dataStr.trim();
        this.gunNum = DataUtil.getGunNum(dataStr.substring(0, 2), this.source);
        dataStr = dataStr.substring(3);
        this.operator = dataStr.substring(0, 2);
        dataStr = dataStr.substring(3);
        this.result = dataStr.substring(0, 2);
        dataStr = dataStr.substring(3);
        if (dataStr.length() > 2) {
            this.money = DataUtil.getBDValue(dataStr, 2, false);// 两位小数
        } else {
            this.reason = dataStr;
        }
        return this;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getGunNum() {
        return gunNum;
    }

    public void setGunNum(String gunNum) {
        this.gunNum = gunNum;
    }


}
